*
*	Define variables for welfare analysis
*

* Create rank
gen int rank = jelsorsz
lab var rank "Rank"

* Create contract id
sort id rank
egen contract_id_temp = group(karkod szaknev szint munkarend fin_form)
tostring contract_id_temp, replace
gen contract_id = "C" + contract_id_temp
lab var contract_id "Contract id"
drop contract_id_temp

* Create program id
sort id rank
egen program_id_temp = group(karkod szaknev szint munkarend)
tostring program_id_temp, replace
gen program_id = "P" + program_id_temp
lab var program_id "Program id"
drop program_id_temp

* Create state-funded
gen byte state_funded = fin_form == 1
lab var state_funded "State-funded contract"
label values state_funded state_funded

* Create applicant id
sort id rank
egen applicant_id_temp = group(id)
tostring applicant_id_temp, replace
gen applicant_id = "A" + applicant_id_temp
lab var applicant_id "Applicant id"
drop applicant_id_temp

* Create admitted
gen byte admitted = felv_sorsz1 == jelsorsz
lab var admitted "Admitted (admin)"

* Create priority-score cutoff
rename ponthatar priority_score_cutoff
lab var priority_score_cutoff "Priority score cutoff"
